/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */

package service.enumerations;

/**
 *
 * @author chapmand
 */
public enum LabResult {
    UNCOMPLETED(0),
    PASS(1),
    INDETERMINATE(2),
    FAIL(3),
    RESTEST(4);
    
    private int result;

    LabResult(final int result) {
            this.result = result;
    }

    public int getResult() {
            return result;
    }

    public static LabResult getResult(final String result) {
            return getResult(Integer.parseInt(result));
    }
    
    public static LabResult getResult(final int result) {
        switch (result) {
        case 0:
            return UNCOMPLETED;
        case 1:
            return PASS;
        case 2:
            return INDETERMINATE;
        case 3:
            return FAIL;
        case 4:
            return RESTEST;
        default:
            throw new EnumConstantNotPresentException(LabResult.class, String.valueOf(result));
        }
    }
    
    public static int getResultByName(final String str) {
        if(str.equals("UNCOMPLETED")){
            return 0;
        } else if(str.equals("PASS")){
            return 1;
        } else if(str.equals("INDETERMINATE")){
            return 2;
        } else if(str.equals("FAIL")){
            return 3;
        } else if(str.equals("RESTEST")){
            return 4;
        } else {
            return 0;
        }
    }
    
    public static String getResultDescription(final int result) {
        switch (result) {
            case 0:
                return "Lab not yet completed: ";
            case 1:
                return "Lab passed: ";
            case 2:
                return "Lab is indeterminate: ";
            case 3:
                return "Lab failed: ";
            case 4:
                return "Need to re-test: ";
            default:
                throw new EnumConstantNotPresentException(LabResult.class, String.valueOf(result));
        }
    }
}
